
package Relationship.Complex.Importing;

import java.util.Collection;
import java.util.Vector;

/**
 * New Class to bulid one kind of entry to show icon and text informations on
 * list of output annotations into xml files.
 *
 * @author Jianwei Leng  2010-06-29
 */
public class iListEntry {
  public String term;
  public Vector<String> subTerms = new Vector<String>();
  public Vector<String> subTerms2 = new Vector<String>();
  public boolean isCheckBoxSelected = true;
  public boolean selected = true;
  private boolean nameKnown;
  public boolean relationship;

  public iListEntry(String term, Collection subTerm, Collection subTerm2, boolean relationship, boolean nameKnown) {
      if(subTerm != null)
        subTerms.addAll(subTerm);
      else
          subTerms = new Vector<String>();
      if(subTerm2 != null)
          subTerms2.addAll(subTerm2);
      else
          subTerms2 = new Vector<String>();
      this.term = term;
      this.relationship = relationship;
      this.nameKnown = nameKnown;

  }

  public String getTitle() {
      String str = "<html>" ;
      if(relationship)
          str += "<b>Relationship Name: </b>";
      else
      {
          str += "<b>Attribute name: </b>";
      }
      if(!nameKnown)
          str+= "<font color = \"red\">";
      str+= term;
      if(!nameKnown)
          str+= "</font>";
      if(!relationship)
      {
          if(subTerms.size() > 0 )
              str += "<br> <b>Attribute Values:</b> ";
          for(String s : subTerms)
          {
              str+= "<br><font color = \"red\">&nbsp; &nbsp; &nbsp; &nbsp;"+ s +"</font>";
          }
      }
      else
      {
          if(subTerms.size() > 0 )
          {
              if(subTerms2 != null)
                  str += "<br> <b>From Markables:</b> ";
              else
                  str += "<br> <b>Allowable Regex:</b> ";
          }
          for(String s : subTerms)
          {
              str+= "<br><font color = \"red\">&nbsp; &nbsp; &nbsp; &nbsp;"+ s +"</font>";
          }
          if(subTerms2 != null)
          {
              if(subTerms2.size() > 0 )
                  str += "<br> <b>To Markables:</b> ";
              for(String s : subTerms2)
              {
                  str+= "<br><font color = \"red\">&nbsp; &nbsp; &nbsp; &nbsp;"+ s +"</font>";
              }
          }
      }
      str+= "</html>";
      return str;
  }
    public void setCheckBoxStatus(boolean isCheckBoxSelected ){
        this.isCheckBoxSelected = isCheckBoxSelected;
    }

  // Override standard toString method to give a useful result
  public String toString() {
      return term;
  }
}